package me.lwn.auth.security.oauth2.server.authorization;

import java.util.HashSet;
import java.util.Set;

public class ServerSetting {

    // TokenSetting
    //access_token有效期（秒）
    private long accessTokenTimeToLive = 1800L;
    //refresh_token有效期（秒）
    private long refreshTokenTimeToLive = 1800L;
    //是否复用refresh_token
    private boolean reuseRefreshTokens = false;
    //state有效期（秒）
    private long stateTimeToLive = 300L;
    //authorization code有效期（秒） 暂时不做实现，后期等官方实现
    private long authCodeTimeToLive = 300L;
    private boolean globalTokenSetting = true;

    // ClientSetting
    private boolean requireProofKey = false;
    private boolean requireAuthorizationConsent = false;
    private String tokenEndpointAuthenticationSigningAlgorithm;
    private String jwkSetUrl;
    private int userLoginFailLockTimes = -1;
    private int loginFailLockedDuration = 300;
    private boolean ipLoginFailLocked = false;
    private boolean requireCaptcha = false;
    private boolean customizeLoginPage = false;
    private boolean globalClientSetting = true;

    // ServerSetting
    private long smsCodeTimeToLive = 300L;
    private int passwordLength = 8;
    private Set<Integer> passwordRules = new HashSet<Integer>() {
        {
            add(1);
            add(2);
            add(4);
        }
    };
    private boolean passwordRegularChange = false;
    private int passwordRegularChangeTimeInterval = 90;

    public long getAccessTokenTimeToLive() {
        return accessTokenTimeToLive;
    }

    public void setAccessTokenTimeToLive(long accessTokenTimeToLive) {
        this.accessTokenTimeToLive = accessTokenTimeToLive;
    }

    public long getRefreshTokenTimeToLive() {
        return refreshTokenTimeToLive;
    }

    public void setRefreshTokenTimeToLive(long refreshTokenTimeToLive) {
        this.refreshTokenTimeToLive = refreshTokenTimeToLive;
    }

    public boolean isReuseRefreshTokens() {
        return reuseRefreshTokens;
    }

    public void setReuseRefreshTokens(boolean reuseRefreshTokens) {
        this.reuseRefreshTokens = reuseRefreshTokens;
    }

    public long getStateTimeToLive() {
        return stateTimeToLive;
    }

    public void setStateTimeToLive(long stateTimeToLive) {
        this.stateTimeToLive = stateTimeToLive;
    }

    public long getAuthCodeTimeToLive() {
        return authCodeTimeToLive;
    }

    public void setAuthCodeTimeToLive(long authCodeTimeToLive) {
        this.authCodeTimeToLive = authCodeTimeToLive;
    }

    public boolean isGlobalTokenSetting() {
        return globalTokenSetting;
    }

    public void setGlobalTokenSetting(boolean globalTokenSetting) {
        this.globalTokenSetting = globalTokenSetting;
    }

    public boolean isRequireProofKey() {
        return requireProofKey;
    }

    public void setRequireProofKey(boolean requireProofKey) {
        this.requireProofKey = requireProofKey;
    }

    public boolean isRequireAuthorizationConsent() {
        return requireAuthorizationConsent;
    }

    public void setRequireAuthorizationConsent(boolean requireAuthorizationConsent) {
        this.requireAuthorizationConsent = requireAuthorizationConsent;
    }

    public String getTokenEndpointAuthenticationSigningAlgorithm() {
        return tokenEndpointAuthenticationSigningAlgorithm;
    }

    public void setTokenEndpointAuthenticationSigningAlgorithm(String tokenEndpointAuthenticationSigningAlgorithm) {
        this.tokenEndpointAuthenticationSigningAlgorithm = tokenEndpointAuthenticationSigningAlgorithm;
    }

    public String getJwkSetUrl() {
        return jwkSetUrl;
    }

    public void setJwkSetUrl(String jwkSetUrl) {
        this.jwkSetUrl = jwkSetUrl;
    }

    public int getUserLoginFailLockTimes() {
        return userLoginFailLockTimes;
    }

    public void setUserLoginFailLockTimes(int userLoginFailLockTimes) {
        this.userLoginFailLockTimes = userLoginFailLockTimes;
    }

    public int getLoginFailLockedDuration() {
        return loginFailLockedDuration;
    }

    public void setLoginFailLockedDuration(int loginFailLockedDuration) {
        this.loginFailLockedDuration = loginFailLockedDuration;
    }

    public boolean isIpLoginFailLocked() {
        return ipLoginFailLocked;
    }

    public void setIpLoginFailLocked(boolean ipLoginFailLocked) {
        this.ipLoginFailLocked = ipLoginFailLocked;
    }

    public boolean isRequireCaptcha() {
        return requireCaptcha;
    }

    public void setRequireCaptcha(boolean requireCaptcha) {
        this.requireCaptcha = requireCaptcha;
    }

    public boolean isCustomizeLoginPage() {
        return customizeLoginPage;
    }

    public void setCustomizeLoginPage(boolean customizeLoginPage) {
        this.customizeLoginPage = customizeLoginPage;
    }

    public boolean isGlobalClientSetting() {
        return globalClientSetting;
    }

    public void setGlobalClientSetting(boolean globalClientSetting) {
        this.globalClientSetting = globalClientSetting;
    }

    public long getSmsCodeTimeToLive() {
        return smsCodeTimeToLive;
    }

    public void setSmsCodeTimeToLive(long smsCodeTimeToLive) {
        this.smsCodeTimeToLive = smsCodeTimeToLive;
    }

    public int getPasswordLength() {
        return passwordLength;
    }

    public void setPasswordLength(int passwordLength) {
        this.passwordLength = passwordLength;
    }

    public Set<Integer> getPasswordRules() {
        return passwordRules;
    }

    public void setPasswordRules(Set<Integer> passwordRules) {
        this.passwordRules = passwordRules;
    }

    public boolean isPasswordRegularChange() {
        return passwordRegularChange;
    }

    public void setPasswordRegularChange(boolean passwordRegularChange) {
        this.passwordRegularChange = passwordRegularChange;
    }

    public int getPasswordRegularChangeTimeInterval() {
        return passwordRegularChangeTimeInterval;
    }

    public void setPasswordRegularChangeTimeInterval(int passwordRegularChangeTimeInterval) {
        this.passwordRegularChangeTimeInterval = passwordRegularChangeTimeInterval;
    }
}
